import { Column, Entity, Index, PrimaryGeneratedColumn } from "typeorm";

@Index("ak_user_address", ["address"], { unique: true })
@Index("ix_user_realname", ["realName"], {})
@Entity("tb_user", { schema: "db_test" })
export class TbUser {
  @PrimaryGeneratedColumn({ type: "int", name: "id", unsigned: true })
  id: number;

  @Column("varchar", {
    name: "address",
    nullable: true,
    unique: true,
    comment: "用户地址",
    length: 50,
    default: () => "''",
  })
  address: string | null;

  @Column("varchar", {
    name: "real_name",
    nullable: true,
    comment: "真实姓名",
    length: 255,
    default: () => "''",
  })
  realName: string | null;

  @Column("varchar", {
    name: "nick_name",
    nullable: true,
    comment: "昵称",
    length: 255,
    default: () => "''",
  })
  nickName: string | null;

  @Column("smallint", {
    name: "age",
    nullable: true,
    comment: "年龄",
    unsigned: true,
    default: () => "'0'",
  })
  age: number | null;

  @Column("timestamp", {
    name: "created_at",
    nullable: true,
    comment: "创建时间",
    default: () => "'0000-00-00 00:00:00'",
  })
  createdAt: Date | null;

  @Column("timestamp", {
    name: "updated_at",
    nullable: true,
    comment: "更新时间",
    default: () => "'0000-00-00 00:00:00'",
  })
  updatedAt: Date | null;
}
